<?php

namespace app\common\model\mysql;

class Comments extends BaseModel
{
    protected $schema=[
        'id'=>'int',
        'associated_id'=>'int',
        'user_id'=>'int',
        'type'=>'tinyint',
        'comments'=>'text',
        'score'=>'int',
        'create_time'=>'int',
        'update_time'=>'int',
        'status'=>'tinyint',
        'work_id'=>'int',
        'work_rob_id'=>'int'
    ];

    public function work(){
        return $this->belongsTo(Work::class,'work_id');
    }

    public function user(){
        return $this->belongsTo(User::class,'user_id');
    }

    //type in 1 公司评价工人 associated_id为工人 user_id为公司
    public function departmentUser(){
        return $this->belongsTo(Department::class,'user_id');
    }
    public function associatedUser(){
        return $this->belongsTo(User::class,'associated_id');
    }
    //type in 2,3 雇主及工人对公司的评价 associated_id为公司 user_id为用户
    public function department(){
        return $this->belongsTo(Department::class,'associated_id');
    }
}
